<template>
	<view>
		<view class="item-input">
			<text>姓名:</text><input v-model="name" type="text" placeholder="请填写姓名">
		</view>
		<view class="item-input">
			<text>手机号:</text><input type="text" disabled='true' v-model="phone">
		</view>
		<view class="btnBox">
			<view class="btn-save del-btn" @click="delHome">
				删除
			</view>
			<view class="btn-save" @click="saveEdit">
				保存
			</view>
		</view>
		
	</view>
</template>

<script>
	import http from '@/shopro/request/index'
	export default {
		data() {
			return {
				name:'',
				phone:'',
				id:''
			};
		},
		onLoad(options) {
			console.log(options);
			this.name = options.name
			this.phone = options.phone
			this.id = options.id
		},
		methods:{
			saveEdit(){
				http('user.saveEditHome',{
					name:this.name,
					id:this.id
				}).then(res=>{
					console.log(res);
					if(res.code==1){
						uni.showToast({
							title:'修改成功'
						})
					}
				})
			},
			delHome(){
				let iid = this.id
				uni.showModal({
					title:'提示',
					content:'确定删除此家属?',
					success:function(res){
						if (res.confirm) {
									console.log('用户点击确定',iid);
									// http('user.delEditHome',{
									// 	// name:this.name,
									// 	id:iid
									// }).then(res=>{
									// 	console.log(res);
									// 	if(res.code==1){
									// 		uni.showToast({
									// 			title:'修改成功'
									// 		})
									// 	}
									// })
									http('user.delEditHome',{
										id:iid
									}).then(res=>{
										if(res.code==1){
											uni.showToast({
												title:'删除成功'
											})
											let uu = uni
											setTimeout(()=>{
												uu.navigateBack()
											},1500)
										}
									})
								} else if (res.cancel) {
									console.log('用户点击取消');
								}
					}
				})
				// http('user.delEditHome',{
				// 	id:this.id
				// }).then(res=>{
				// 	if(res.code==1){
						
				// 	}
				// })
			}
		}
	}
</script>

<style lang="scss">
.item-input {
	display: flex;
	align-items: center;
	background-color: #fff;
	padding:20px 9px ;
	position: relative;
	text {
		min-width: 18%;
	}
	font-size: 20px;
	input {
		font-size: 20px;
	}
	&::after {
		content: '';
		position: absolute;
		width: 94%;
		bottom: 0;
		left: 50%;
		height: 1px;
		background-color: #e5e5e5;
		transform: translateX(-50%);
	}
	// border-bottom: 1px solid #e5e5e5;
}
.btnBox {
	display: flex;
	width: 94%;
	margin: 0 auto;
}
.btn-save {
	// width: 94%;
	flex: 1;
	margin: 24px auto 0;
	height: 45px;
		background-image: linear-gradient(90deg, 
			#ff8300 0%, 
			#ff3d00 100%), 
		linear-gradient(
			#ffffff, 
			#ffffff);
		background-blend-mode: normal, 
			normal;
		border-radius: 23px;
		line-height: 45px;
		text-align: center;
		color: #ffffff;
		font-size: 20px;
}
.del-btn {
	flex: 1;
	background-color: #cfcfcf;
	background-image: unset;
	margin-right: 11px;
	color: #838383;
}
</style>
